/**
 * Copyright (c) 2012-2016, www.tinygroup.org (luo_guo@icloud.com).
 *
 *  Licensed under the GPL, Version 3.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *       http://www.gnu.org/licenses/gpl.html
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package org.tinygroup.aopcache;

import org.aopalliance.intercept.MethodInvocation;
import org.tinygroup.aopcache.base.CacheMetadata;

/**
 * aop缓存处理接口
 *
 * @author renhui
 */
public interface AopCacheProcessor {

    /**
     * 前置处理操作
     *
     * @param metadata
     * @param invocation
     * @return true:可以执行下一个处理器,false:认为流程已经执行完毕，调用
     */
    boolean preProcess(CacheMetadata metadata, MethodInvocation invocation);

    /**
     * @param metadata
     * @param invocation 后置处理操作
     * @param result     执行结果
     */
    void postProcess(CacheMetadata metadata, MethodInvocation invocation, Object result);

    /**
     * @param metadata
     * @param invocation 流程结束操作,方法返回值作为AopCacheInterceptor。invoke(MethodInvocation
     *                   invocation)方法的返回值
     * @return
     */
    Object endProcessor(CacheMetadata metadata, MethodInvocation invocation);

}
